<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
    </style>
</head>
<body>
    <div id="app" class="app">
        <h1>{{message}}</h1>
        <h1>{{getDate()}}</h1>
    </div>

    <script src="vue.min.js"></script>
    <script>
        const app = new Vue({
            el:"#app",
            data:{
                message:"hello world！",
                date: ''
            },
            methods: {
                getDate() {
                    var date = new Date();
                    return date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate()
                }
            },
            mounted(){
                var eventSource = new EventSource("http://localhost:8080/test/helloworld");
                var _this = this;
                eventSource.onmessage = function (event) {
                    _this.date = "message: " + event.data;
                };
                eventSource.addEventListener("end", function (event) {
                    console.info(event)
                    eventSource.close();
                })
            }
        })
    </script>
</body>
</html>